//
// Created by miaomiaole on 2023/4/9.
//

#ifndef CMAKECXX_RAINBOW_H
#define CMAKECXX_RAINBOW_H

#include <iostream>
// xsetjmp 保存错误栈信息
#include <csetjmp>

class Rainbow {
public:
    Rainbow() {
        std::cout << "RainBow" << std::endl;
    }

    ~Rainbow() {
        std::cout << "~ RainBow" << std::endl;
    }

    jmp_buf kansas;

    void oz() {
        Rainbow rb;

        for (int i = 0; i < 3; ++i) {
            std::printf("there is no place kike some");
            longjmp(kansas, 47);
        }
    }
};


class MyError {
    // data变量不允许二次变动
    const char *const data;
public:
    MyError(const char *const msg = 0) : data(msg) {};

    void f() {
        throw MyError("Something bad happend");
    }
};


#endif //CMAKECXX_RAINBOW_H
